//
//  HMImageView.m
//  仿写SDWebImage
//
//  Created by 倪啸天 on 16/10/15.
//  Copyright © 2016年 itheima. All rights reserved.
//

#import "HMImageView.h"
#import "NSOperationManager.h"
#import "HMDownloadIMGOperation.h"

@interface HMImageView ()

@property (nonatomic, copy) NSString *currentUrlString;

@end

@implementation HMImageView



- (void)HM_downloadIMGWithUrlString:(NSString *)urlString {

    //取消
    if (![_currentUrlString isEqualToString:urlString]) {
        [[NSOperationManager shareManager] cancelOperationWithUrlString:_currentUrlString];
    }
    
    self.currentUrlString = urlString;
    
    //下载
    [[NSOperationManager shareManager] downloadIMGWithUrlString:urlString andCompletedBlock:^(UIImage *image) {
        self.image = image;
    }];
    
}

@end
